package com.hb.core.pojo.enums;

import lombok.Data;
import lombok.Getter;

/**
 * Websocket即时消息类别枚举类（业务相关）
 *
 * @author Lix1ang
 * @date 2022-1-12 10:11:41
 */
@Getter
public enum TradeWebsocketMsgEnum {

    HALL_SIGNIN_START(10, "开标大厅签到开始", 1),
    HALL_BIDOPENING_START(11, "开标大厅开标开始", 2),
    HALL_DECRYPT_START(12, "开标大厅解密开始", 3),
    HALL_DECRYPT_END(13, "开标大厅解密结束", 4),
    HALL_SING_END(14, "开标大厅唱标开始", 5),
    HALL_CONFIRM_START(15, "开标大厅确认开始", 6),
    HALL_CONFIRM_END(16, "开标大厅确认结束", 6),
    HALL_BIDOPENING_END(17, "开标大厅开标结束", 7),
    HALL_FLOW(18, "开标大厅流标", 8),

    HALL_BIDDER_SIGNIN(20, "投标人签到", 1),
    HALL_BIDDER_DECRYPT(21, "投标人解密", 3),
    HALL_BIDDER_COMFIRM(22, "投标人确认", 6),

    HALL_TIME_TASK(26, "当前系统时间", 0),
    HALL_PLAY_DISCIPLINE(27, "播放会场纪律", 0),
    BID_EVALUATION(28, "是否评标", 0),
    SUPPLIER_QUOTE_AGAIN(29, "供应商再次报价", 1),
    EXPERT_QUOTE_AGAIN(30, "专家发起再次报价", 1),
    MESSAGE_CENTER(31, "消息中心", 1),
    STOP_PLAY(32, "开标大厅暂停播放声音", 1),
    EXPERT_QUOTE_TERM(33, "专家发起再次报价(刷新报价项)", 1);

    private final Integer code;
    private final String showName;
    private final Integer status;

    TradeWebsocketMsgEnum(Integer code, String showName, Integer status) {
        this.code = code;
        this.showName = showName;
        this.status = status;
    }

    /**
     * 根据code获取枚举类实例
     *
     * @param code
     * @return
     */
    public static TradeWebsocketMsgEnum getIns(Integer code) {
        if (null == code) {
            return null;
        }
        TradeWebsocketMsgEnum[] values = TradeWebsocketMsgEnum.values();
        for (TradeWebsocketMsgEnum tradeWebsocketMsgEnum : values) {
            if (code.equals(tradeWebsocketMsgEnum.getCode())) {
                return tradeWebsocketMsgEnum;
            }
        }
        return null;
    }


    /**
     * 根据开标状态获取枚举类实例
     *
     * @param openingStatus 开标状态
     * @param isEndSign     是否结束签名(1:未结束 2:已结束)
     * @return com.hb.core.pojo.enums.TradeWebsocketMsgEnum
     * @author tian
     * @date 2022-2-28 16:32
     */
    public static TradeWebsocketMsgEnum getInsByOpeningStatus(Integer openingStatus, Integer isEndSign) {
        if (null == openingStatus) {
            return null;
        }
        if (openingStatus == 1) {
            return TradeWebsocketMsgEnum.HALL_SIGNIN_START;
        } else if (openingStatus == 2) {
            return TradeWebsocketMsgEnum.HALL_BIDOPENING_START;
        } else if (openingStatus == 3) {
            return TradeWebsocketMsgEnum.HALL_DECRYPT_START;
        } else if (openingStatus == 4) {
            return TradeWebsocketMsgEnum.HALL_DECRYPT_END;
        } else if (openingStatus == 5) {
            return TradeWebsocketMsgEnum.HALL_SING_END;
        } else if (openingStatus == 6 && isEndSign == 1) {
            return TradeWebsocketMsgEnum.HALL_CONFIRM_START;
        } else if (openingStatus == 6 && isEndSign == 2) {
            return TradeWebsocketMsgEnum.HALL_CONFIRM_END;
        } else if (openingStatus == 7) {
            return TradeWebsocketMsgEnum.HALL_BIDOPENING_END;
        } else if (openingStatus == 8) {
            return TradeWebsocketMsgEnum.HALL_FLOW;
        }
        return null;
    }


}
